//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.restaurant.application.indexes.accumulategoodslist;

import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.nebutown.base.ViewSpec;
import com.nebutown.base.data.View;
import com.nebutown.base.data.ViewUpdate;
import com.nebutown.commonunits.dataface.DataModes;
import com.nebutown.commonunits.dataface.DateTypes;
import com.nebutown.commonunits.dataface.EntryTypes;
import com.nebutown.commonunits.dataface.FormShell;
import com.nebutown.commonunits.dataface.TableShell;
import com.nebutown.commonunits.dataface.definitions.ButtonField;
import com.nebutown.commonunits.dataface.definitions.FieldValue;
import com.nebutown.commonunits.dataface.definitions.PageForm;
import com.nebutown.commonunits.dataface.definitions.PageInfo;
import com.nebutown.commonunits.dataface.definitions.TimeInterval;
import com.nebutown.commonunits.uidataface.UIDataFace;
import com.nebutown.commonunits.utils.DateTimeUtils;
import com.nebutown.description.data.SortSpec;
import com.nebutown.generation.basicdata.StringMap;
import com.nebutown.generation.basictype.UID;
import com.restaurant.application.accumulategoods.AccumulateGoods;
import com.restaurant.application.accumulategoodscoupon.AccumulateGoodsCoupon;
import com.restaurant.application.customer.Customer;
import com.restaurant.application.customer.support.AddressData;
import com.restaurant.application.exchangegoods.ExchangeGoods;
import com.restaurant.application.goodscoupon.GoodsCoupon;
import com.restaurant.application.goodscoupon.support.GoodsCouponDetail;
import com.restaurant.application.indexes.accumulategoodslist.mysql.AccumulateGoodsListBean;
import com.restaurant.application.indexes.accumulategoodslist.mysql.AccumulateGoodsListCriteria;
import com.restaurant.application.indexes.accumulategoodslist.mysql.AccumulateGoodsListImpl;
import com.restaurant.application.indexes.accumulategoodslist.support.AbstractAccumulateShop;
import com.restaurant.application.indexes.accumulategoodslist.support.GoodsSearchBean;
import com.restaurant.application.indexes.couponmanagelist.mysql.CouponManageListBean;
import com.restaurant.application.indexes.couponmanagelist.mysql.CouponManageListCriteria;
import com.restaurant.application.indexes.couponmanagelist.mysql.CouponManageListImpl;
import com.restaurant.application.indexes.goodscouponlist.mysql.GoodsCouponListBean;
import com.restaurant.application.indexes.goodscouponlist.mysql.GoodsCouponListCriteria;
import com.restaurant.application.indexes.goodscouponlist.mysql.GoodsCouponListImpl;
import com.restaurant.application.minifacade.data.CardPageBO;
import com.restaurant.application.minifacade.data.ChangeResultBO;
import com.restaurant.application.minifacade.data.DeliveryBO;
import com.restaurant.application.minifacade.data.ExchangeGoodsSearch;
import com.restaurant.application.minifacade.data.GoodsBO;
import com.restaurant.application.minifacade.data.GoodsCouponList;
import com.restaurant.application.minifacade.data.GoodsPageBO;
import com.restaurant.application.minifacade.data.IdBO;
import com.restaurant.application.minifacade.data.SearchGoodsBO;
import com.restaurant.application.minifacade.data.ShopBO;
import com.restaurant.application.shop.support.ShopVo;
import com.restaurant.application.shoplist.ShopList;
import com.restaurant.application.util.CommonUtils;
import com.restaurant.application.util.ResultBean;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class AccumulateShopImpl extends AbstractAccumulateShop {
    public AccumulateShopImpl() {
    }

    public ViewUpdate upGoods(int[] seq) {
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withRecordId((long)seq[0]), (SortSpec)null, 1);
        if (Objects.equals("优惠券", ((AccumulateGoodsListBean)search.get(0)).getGoodsType())) {
            List<CouponManageListBean> search1 = ((CouponManageListImpl)this.getIndex(CouponManageListImpl.class)).search((new CouponManageListCriteria()).withCouponManageUidEquals(UID.recover(((AccumulateGoodsListBean)search.get(0)).getCouponManagement())), (SortSpec)null, 1);
            if (!Objects.equals(((CouponManageListBean)search1.get(0)).getState(), "有效")) {
                return this.returnViewCall(this.buildViewCall(this.unitPosition(), "showErrorMessage", (List)null, (new StringMap()).putData("errorMessage", "该优惠券已失效，不能上架")));
            }

            ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已上架");
        } else {
            ((AccumulateGoods)this.getUnit(AccumulateGoods.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已上架");
        }

        return this.returnView(new View[]{this.getFullView()});
    }

    public ViewUpdate downGoods(int[] seq) {
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withRecordId((long)seq[0]), (SortSpec)null, 1);
        if (Objects.equals("优惠券", ((AccumulateGoodsListBean)search.get(0)).getGoodsType())) {
            ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已下架");
        } else {
            ((AccumulateGoods)this.getUnit(AccumulateGoods.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已下架");
        }

        return this.returnView(new View[]{this.getFullView()});
    }

    public ViewUpdate editGoods(int[] seq) {
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withRecordId((long)seq[0]), (SortSpec)null, 1);
        return this.returnPushInContainer(((AccumulateGoodsListBean)search.get(0)).getGoodsUID(), false);
    }

    public ViewUpdate createOtherGoods(int[] seq) {
        return this.returnPushInContainer(((AccumulateGoods)this.createNode(AccumulateGoods.class)).getId(), false);
    }

    public ViewUpdate createCoupon(int[] seq) {
        return this.returnPushInContainer(((AccumulateGoodsCoupon)this.createNode(AccumulateGoodsCoupon.class)).getId(), false);
    }

    public ViewUpdate showGoodsDetail(int[] seq) {
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withRecordId((long)seq[0]), (SortSpec)null, 1);
        return ((AccumulateGoodsListBean)search.get(0)).getGoodsUID().value().contains("AccumulateGoodsCoupon") ? this.returnView(new View[]{((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).showGoodsCouponDetail(this.unitPosition())}) : this.returnView(new View[]{((AccumulateGoods)this.getUnit(AccumulateGoods.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).showGoodsDetail(this.unitPosition())});
    }

    public ViewUpdate deleteGoods(int[] seq) {
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withRecordId((long)seq[0]), (SortSpec)null, 1);
        if (Objects.equals("已下架", ((AccumulateGoodsListBean)search.get(0)).getState())) {
            if (Objects.equals("优惠券", ((AccumulateGoodsListBean)search.get(0)).getGoodsType())) {
                ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已删除");
            } else {
                ((AccumulateGoods)this.getUnit(AccumulateGoods.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).upDateState("已删除");
            }

            return this.returnView(new View[]{this.getFullView()});
        } else {
            return this.returnViewCall(this.buildViewCall(this.unitPosition(), "showErrorMessage", (List)null, (new StringMap()).putData("errorMessage", "商品未下架，不能删除")));
        }
    }

    public ViewUpdate searchGoods(GoodsSearchBean searchGoods, int[] seq) {
        return this.returnView(new View[]{this.newCommonTable(searchGoods)});
    }

    public ViewUpdate jumpPage(GoodsSearchBean jumpPage, int[] seq) {
        return this.returnView(new View[]{this.newCommonTable(jumpPage)});
    }

    public View getFullView() {
        return this.newCommonTable(new GoodsSearchBean());
    }

    public View getViewLead(ViewSpec viewSpec) {
        return null;
    }

    public GoodsPageBO getMiniPage(IdBO idBO) {
        String levelName = "";
        if (Objects.nonNull(this.getGate())) {
            levelName = ((Customer)this.getUnit(Customer.class, this.getGate())).findData().getLevelName();
        }

        List<ShopBO> shopList = (List)((ShopList)this.getSingleton(ShopList.class)).findAllShopData().stream().map((e) -> {
            return (new ShopBO()).withShopName(e.getName()).withShopId(e.getId());
        }).collect(Collectors.toList());
        List<AccumulateGoodsListBean> beans = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withExchangeLevelLike(levelName).withStateEquals("已上架"), CommonUtils.getSort("CREATETIME"), 0, idBO.getPageSize());
        List<GoodsBO> goodsList = this.getGoodsList(beans);
        UID gate = this.getGate();
        long totalScores = 0L;
        if (gate != null) {
            totalScores = ((Customer)this.getUnit(Customer.class, gate)).getMainBO().getIntegral();
        }

        return (new GoodsPageBO()).withLists(shopList).withIntegral(totalScores).withGoods(goodsList);
    }

    private List<GoodsBO> getGoodsList(List<AccumulateGoodsListBean> goodsList) {
        List<GoodsBO> lists = Lists.newArrayList();
        Iterator var3 = goodsList.iterator();

        while(var3.hasNext()) {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)var3.next();
            if ((Objects.isNull(bean.getSoldNumber()) ? 0L : bean.getSoldNumber()) < bean.getGoodsNumber()) {
                GoodsBO goodsBO = (new GoodsBO()).withName(bean.getGoodsName()).withIntegral(bean.getAccumulatePoints()).withDescription(bean.getGoodsDescribe()).withGoodsId(bean.getGoodsId()).withPrice(Objects.nonNull(bean.getPrice()) ? bean.getPrice().toString() : "").withValidShop(bean.getShopName());
                String images;
                if (bean.getGoodsUID().value().contains("AccumulateGoodsCoupon")) {
                    images = ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, bean.getGoodsUID())).getGoodsData().getImages();
                    goodsBO.withImgUrl(images);
                } else if (bean.getGoodsUID().value().contains("AccumulateGoods")) {
                    images = ((AccumulateGoods)this.getUnit(AccumulateGoods.class, bean.getGoodsUID())).getGoodsData().getImages();
                    goodsBO.withImgUrl(images);
                }

                if (Objects.equals(bean.getGoodsType(), "优惠券")) {
                    List<CouponManageListBean> search = ((CouponManageListImpl)this.getIndex(CouponManageListImpl.class)).search((new CouponManageListCriteria()).withCouponManageUidEquals(UID.recover(bean.getCouponManagement())), (SortSpec)null, 1);
                    goodsBO.withFromTime(((CouponManageListBean)search.get(0)).getReceiveTime()).withEndTime(((CouponManageListBean)search.get(0)).getEndTime()).withNumberLimit((int)(bean.getGoodsNumber() - (Objects.isNull(bean.getSoldNumber()) ? 0L : bean.getSoldNumber())));
                    if (!Objects.equals("已过期", ((CouponManageListBean)search.get(0)).getState())) {
                        lists.add(goodsBO);
                    } else {
                        ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, bean.getGoodsUID())).upDateState("已下架");
                    }
                } else {
                    lists.add(goodsBO);
                }
            } else if (Objects.equals(bean.getGoodsType(), "优惠券")) {
                ((AccumulateGoodsCoupon)this.getUnit(AccumulateGoodsCoupon.class, bean.getGoodsUID())).upDateState("已下架");
            } else {
                ((AccumulateGoods)this.getUnit(AccumulateGoods.class, bean.getGoodsUID())).upDateState("已下架");
            }
        }

        return lists;
    }

    public GoodsPageBO miniSearchGoods(SearchGoodsBO data) {
        String levelName = "";
        if (Objects.nonNull(this.getGate())) {
            levelName = ((Customer)this.getUnit(Customer.class, this.getGate())).findData().getLevelName();
        }

        if (Objects.isNull(data.getPage())) {
            data.setPage(1);
        }

        List<AccumulateGoodsListBean> goodsList = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withStateEquals("已上架").withGoodsNameLike(data.getContent()).withShopIdLike(data.getShopId()).withExchangeLevelLike(levelName), CommonUtils.getSort(), (data.getPage() - 1) * data.getPageSize(), data.getPageSize() * data.getPage());
        List<GoodsBO> collect = this.getGoodsList(goodsList);
        return (new GoodsPageBO()).withGoods(collect);
    }

    public ResultBean<ChangeResultBO> exchangeGoods(IdBO data) {
        ChangeResultBO resultBO = new ChangeResultBO();
        UID customerUid = this.getGate();
        List<AccumulateGoodsListBean> search = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search((new AccumulateGoodsListCriteria()).withGoodsIdEquals(data.getId()), (SortSpec)null, 1);
        ResultBean<IdBO> resultBean = new ResultBean();
        if (search.size() > 0) {
            if (!Objects.equals(((AccumulateGoodsListBean)search.get(0)).getGoodsType(), "优惠券")) {
                List<String> deliveryType = ((AccumulateGoods)this.getUnit(AccumulateGoods.class, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID())).getGoodsData().getDeliveryType();
                resultBO.setLists(deliveryType);
            }

            resultBean = ((ExchangeGoods)this.createNode(ExchangeGoods.class)).setExchangeGoodsData(customerUid, ((AccumulateGoodsListBean)search.get(0)).getGoodsUID(), ((AccumulateGoodsListBean)search.get(0)).getGoodsType());
            if (Objects.nonNull(resultBean.getData())) {
                resultBO.setGoodsId(((IdBO)resultBean.getData()).getId());
            }
        }

        ResultBean<ChangeResultBO> bean = new ResultBean();
        bean.setMessage(resultBean.getMessage());
        bean.setData(resultBO);
        return bean;
    }

    public GoodsCouponDetail goodsCouponDetail(IdBO data) {
        List<GoodsCouponListBean> search = ((GoodsCouponListImpl)this.getIndex(GoodsCouponListImpl.class)).search((new GoodsCouponListCriteria()).withCouponNumberEquals(data.getId()), (SortSpec)null, 1);
        return search.size() > 0 ? ((GoodsCoupon)this.getUnit(GoodsCoupon.class, ((GoodsCouponListBean)search.get(0)).getGoodsCoupon())).getGoodsDetail() : new GoodsCouponDetail();
    }

    public ResultBean confirmDelivery(DeliveryBO detail) {
        ResultBean resultBean = new ResultBean();
        GoodsCouponDetail couponDetail = new GoodsCouponDetail();
        if (!Strings.isNullOrEmpty(detail.getAddressId())) {
            AddressData addressData = ((Customer)this.getUnit(Customer.class, this.getGate())).getAddressDataById(detail.getAddressId());
            couponDetail.withAddress(CommonUtils.removeNullStr(addressData.getProvince()) + CommonUtils.removeNullStr(addressData.getCity()) + CommonUtils.removeNullStr(addressData.getCounty()) + CommonUtils.removeNullStr(addressData.getAddress()));
            couponDetail.withType("物流配送");
        } else {
            couponDetail.withType("到店自提");
        }

        List<GoodsCouponListBean> search = ((GoodsCouponListImpl)this.getIndex(GoodsCouponListImpl.class)).search((new GoodsCouponListCriteria()).withCouponNumberEquals(detail.getGoodsId()), (SortSpec)null, 1);
        if (search.size() > 0) {
            String s = ((GoodsCoupon)this.getUnit(GoodsCoupon.class, ((GoodsCouponListBean)search.get(0)).getGoodsCoupon())).perfectData(couponDetail);
            resultBean.setMessage(s);
        }

        return resultBean;
    }

    public ResultBean getMyExchangeGoodsList(ExchangeGoodsSearch idBO) {
        ResultBean resultBean = new ResultBean();
        if (!Strings.isNullOrEmpty(idBO.getId())) {
            resultBean = this.confirmDelivery((new DeliveryBO()).withGoodsId(idBO.getId()));
        }

        UID gate = this.getGate();
        if (Objects.isNull(idBO.getPage())) {
            idBO.setPage(1);
        }

        List<GoodsCouponListBean> search = ((GoodsCouponListImpl)this.getIndex(GoodsCouponListImpl.class)).search((new GoodsCouponListCriteria()).withCurrentCustomerUidEquals(gate.value()).withUsefulLike(idBO.getState()), CommonUtils.getSort("CREATETIME"), (idBO.getPage() - 1) * idBO.getPageSize(), idBO.getPage() * idBO.getPageSize());
        List<GoodsCouponDetail> collect = (List)search.stream().map((e) -> {
            return ((GoodsCoupon)this.getUnit(GoodsCoupon.class, e.getGoodsCoupon())).getGoodsDetail();
        }).collect(Collectors.toList());
        resultBean.setData((new GoodsCouponList()).withLists(collect));
        resultBean.setMessage("success");
        return resultBean;
    }

    public ResultBean confirmGoodsCoupon(CardPageBO idBO) {
        ResultBean resultBean = new ResultBean();
        List<GoodsCouponListBean> search = ((GoodsCouponListImpl)this.getIndex(GoodsCouponListImpl.class)).search((new GoodsCouponListCriteria()).withCouponNumberEquals(idBO.getCardId()), (SortSpec)null, 1);
        if (search.size() > 0) {
            String s = ((GoodsCoupon)this.getUnit(GoodsCoupon.class, ((GoodsCouponListBean)search.get(0)).getGoodsCoupon())).confirmReceive(idBO.getVersion());
            resultBean.setMessage(s);
        } else {
            resultBean.setMessage("查无此券，不能领用");
        }

        return resultBean;
    }

    private View newCommonTable(GoodsSearchBean criteria) {
        int pageNum = Objects.nonNull(criteria.getPage()) ? criteria.getPage().intValue() : 1;
        int pageSize = 10;
        int start = (pageNum - 1) * pageSize;
        int stop = pageNum * pageSize;
        int totalRecord = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).count(this.translate(criteria));
        int totalPage = (totalRecord + pageSize - 1) / pageSize;
        List<AccumulateGoodsListBean> goodsList = ((AccumulateGoodsListImpl)this.getIndex(AccumulateGoodsListImpl.class)).search(this.translate(criteria), CommonUtils.getSort(), start, stop);
        PageInfo pageInfo = new PageInfo(Integer.valueOf(pageSize), pageNum, totalPage, totalRecord, this.getPath(CMD_JUMPPAGE, new int[0]), "page");
        PageForm pageForm = this.newFormShell(criteria, goodsList, pageInfo).getForm();
        return ((UIDataFace)this.getSingleton(UIDataFace.class)).newUniForm(this.unitPosition(), pageForm);
    }

    private FormShell newFormShell(GoodsSearchBean criteria, List<AccumulateGoodsListBean> goodsList, PageInfo pageInfo) {
        FormShell formShell = new FormShell("积分商城/积分商品", 3, 6);
        formShell.source(criteria, DataModes.EDIT);
        formShell.at(0, 0, "商品名称").stringField("goodsName", criteria.getGoodsName()).placeHolder("商品名").setEditable(true);
        formShell.at(0, 1, "商品Id").stringField("goodsId", criteria.getGoodsId()).placeHolder("商品Id").setEditable(true);
        List<String> collect = (List)((ShopList)this.getSingleton(ShopList.class)).findAllShopData().stream().map(ShopVo::getName).collect(Collectors.toList());
        formShell.at(0, 2, "使用门店").selectEntry("useShopName", criteria.getUseShopName(), collect).placeHolder("使用门店").setEditable(true);
        formShell.at(1, 0, "创建时间").intervalField("createTime", criteria.getCreateTime(), DateTypes.DATETIME).notNull().setEditable(true);
        formShell.at(1, 1, "上架时间").intervalField("upTime", criteria.getCreateTime(), DateTypes.DATETIME).notNull().setEditable(true);
        List<String> states = Lists.newArrayList(new String[]{"已下架", "已上架"});
        formShell.at(3, 0, "状态").selectEntry("state", criteria.getState(), states).placeHolder("状态").setEditable(true);
        List<String> category = Lists.newArrayList(new String[]{"优惠券", "其他"});
        formShell.at(3, 1, "种类").selectEntry("category", criteria.getCategory(), category).placeHolder("种类").setEditable(true);
        List<ButtonField> buttons = Lists.newArrayList();
        buttons.add(new ButtonField(this.getPath(CMD_SEARCHGOODS, new int[0]), "搜索", true, (String)null, false));
        if (!Strings.isNullOrEmpty(this.getPath(CMD_CREATECOUPON, new int[0]))) {
            buttons.add(new ButtonField(this.getPath(CMD_CREATECOUPON, new int[0]), "创建优惠券商品", false, (String)null, false));
        }

        if (!Strings.isNullOrEmpty(this.getPath(CMD_CREATEOTHERGOODS, new int[0]))) {
            buttons.add(new ButtonField(this.getPath(CMD_CREATEOTHERGOODS, new int[0]), "创建其他商品", false, (String)null, false));
        }

        formShell.at(4, 0, "").large(2, 1).buttonBoxField((ButtonField[])buttons.toArray(new ButtonField[0]));
        TableShell<AccumulateGoodsListBean> tableShell = (new TableShell(AccumulateGoodsListBean.class, goodsList)).withPageInfo(pageInfo);
        tableShell.createColumn("goodsName").withName("商品名").withWidth(100).cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getGoodsName());
        });
        tableShell.createColumn("goodsType").withName("种类").withWidth(80).cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getGoodsType());
        });
        tableShell.createColumn("shopName").withWidth(100).withName("门店").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getShopName());
        });
        tableShell.createColumn("goodsNumber").withWidth(80).withName("总数量").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getGoodsNumber().toString());
        });
        tableShell.createColumn("soldNumber").withWidth(90).withName("已售数量").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getSoldNumber().toString());
        });
        tableShell.createColumn("accumulatePoints").withWidth(90).withName("所需积分").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(bean.getAccumulatePoints().toString());
        });
        tableShell.createColumn("createTime").withWidth(160).withName("创建时间").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(DateTimeUtils.toTime(bean.getCreateTime()));
        });
        tableShell.createColumn("upTime").withWidth(160).withName("上架时间").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(DateTimeUtils.toTime(bean.getUpTime()));
        });
        tableShell.createColumn("state").withName("状态").cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            return (new FieldValue()).withValue(Strings.isNullOrEmpty(bean.getState()) ? "待上架" : bean.getState());
        });
        tableShell.createColumn("操作").withName("操作").withWidth(350).cellCalculator((b) -> {
            AccumulateGoodsListBean bean = (AccumulateGoodsListBean)b;
            List<ButtonField> fields = Lists.newArrayList();
            if (!Strings.isNullOrEmpty(this.getPath(CMD_SHOWGOODSDETAIL, new int[0]))) {
                fields.add((new ButtonField()).withButtonPath(this.getPath(CMD_SHOWGOODSDETAIL, new long[]{bean.getRecordId()})).withWithData(false).withLabel("查看"));
            }

            if (!Strings.isNullOrEmpty(this.getPath(CMD_EDITGOODS, new int[0]))) {
                fields.add((new ButtonField()).withButtonPath(this.getPath(CMD_EDITGOODS, new long[]{bean.getRecordId()})).withWithData(false).withLabel("编辑"));
            }

            if (Objects.equals("已上架", bean.getState()) && !Strings.isNullOrEmpty(this.getPath(CMD_DOWNGOODS, new int[0]))) {
                fields.add((new ButtonField()).withButtonPath(this.getPath(CMD_DOWNGOODS, new long[]{bean.getRecordId()})).withWithData(false).withLabel("下架"));
            } else if (!Strings.isNullOrEmpty(this.getPath(CMD_UPGOODS, new int[0]))) {
                fields.add((new ButtonField()).withButtonPath(this.getPath(CMD_UPGOODS, new long[]{bean.getRecordId()})).withWithData(false).withLabel("上架"));
                fields.add((new ButtonField()).withButtonPath(this.getPath(CMD_DELETEGOODS, new long[]{bean.getRecordId()})).withWithData(false).withLabel("删除"));
            }

            return fields.size() > 0 ? (new FieldValue()).withButtonBox(fields).withEntryType(EntryTypes.BUTTONBOX) : (new FieldValue()).withValue("");
        });
        formShell.at(5, 0, "商品表").large(3, 1).tableField("inset", tableShell);
        return formShell;
    }

    private Long dealWithLong(Long timeStamp) {
        if (Objects.nonNull(timeStamp) && timeStamp == 0L) {
            timeStamp = null;
        }

        return timeStamp;
    }

    private AccumulateGoodsListCriteria translate(GoodsSearchBean bean) {
        if (Objects.isNull(bean.getCreateTime())) {
            bean.withCreateTime(new TimeInterval());
        }

        if (Objects.isNull(bean.getUpTime())) {
            bean.withUpTime(new TimeInterval());
        }

        return (new AccumulateGoodsListCriteria()).withGoodsNameLike(CommonUtils.getNullStr(bean.getGoodsName())).withGoodsIdLike(CommonUtils.getNullStr(bean.getGoodsId())).withShopNameLike(CommonUtils.getNullStr(bean.getUseShopName())).withCreateTimeLower(bean.getCreateTime().getFrom()).withCreateTimeUpper(bean.getCreateTime().getTo()).withUpTimeLower(bean.getUpTime().getFrom()).withGoodsTypeLike(CommonUtils.getNullStr(bean.getCategory())).withUpTimeUpper(bean.getUpTime().getTo()).withStateLike(CommonUtils.getNullStr(bean.getState())).withStateNotEquals("已删除");
    }
}
